package com.mew.chess.core.game.bjl.game;

import java.util.HashMap;
import java.util.Map;


/**游戏管理类  单例 房间列表
 * @author dylin
 */
public class BjlGameManager {

    private int gameId;
    private static BjlGameManager bjlGameManager = new BjlGameManager();
    private final Map<Integer, BjlRoomManager> controllerMap = new HashMap<>(8);

    private BjlGameManager(){
    }

    public static BjlGameManager getInstance() {
        if (bjlGameManager == null) {
            synchronized (BjlGameManager.class) {
                if (bjlGameManager == null) {
                    bjlGameManager = new BjlGameManager();
                }
            }
        }
        return bjlGameManager;
    }


    public void putController(BjlRoomManager controller){
        controllerMap.put(controller.getRoomId(), controller);
    }

    public BjlRoomManager getController(Integer roomId){
        return controllerMap.get(roomId);
    }

    public int getGameId() {
        return gameId;
    }

    public void setGameId(int gameId) {
        this.gameId = gameId;
    }
}
